package com.licoba.emoji.ui.fragment.first;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.licoba.emoji.R;
import com.licoba.emoji.base.BaseMainFragment;
import com.licoba.emoji.ui.fragment.first.child.ViewPagerFragment;


public class FirstFragment extends BaseMainFragment {
    public static FirstFragment newInstance() {

        Bundle args = new Bundle();
        FirstFragment fragment = new FirstFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_first, container, false);
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        if (findChildFragment(ViewPagerFragment.class) == null) {
            //如果栈内没有ViewPagerFragment，那么往根布局内加入一个ViewPagerFragment
            loadRootFragment(R.id.fragment_first, ViewPagerFragment.newInstance());
        }
    }



//    @Override
//    public void onLazyInitView(@Nullable Bundle savedInstanceState) {
//        super.onLazyInitView(savedInstanceState);
//        // 这里可以不用懒加载,因为Adapter的场景下,Adapter内的子Fragment只有在父Fragment是show状态时,才会被Attach,Create
//    }
}
